package com.mvc.controller;

import com.alibaba.fastjson.JSON;
import com.mvc.entity.OrderTransaction;
import com.mvc.model.Result;
import com.mvc.service.OrderTransactionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ClassName OrderTransactionController
 * @Description TODO
 * @Author Gla
 * @Date 2021/12/2 11:44
 * @Version 1.0
 **/
@Api(tags = "支付交易")
@Controller
@RequestMapping(value = "/orderTransaction", produces = "text/html;charset=UTF-8")
public class OrderTransactionController {
    @Autowired
    private OrderTransactionService orderTransactionService;

    @ApiOperation(value = "交易支付分页查询",response = Result.class)
    @GetMapping(value = "/search.do")
    @ResponseBody
    public String listSearch(@RequestParam Integer page, @RequestParam Integer limit,
                             @RequestParam(required = false) Integer order_no){

        Integer startRow = (page - 1) * limit;

        List<OrderTransaction> list = orderTransactionService.listSearch(startRow,limit,order_no);
        Integer count = orderTransactionService.getCount(order_no);

        Result result = new Result();
        result.setCode(0);
        result.setCount(count);
        result.setData(list);
        String s = JSON.toJSONString(result);
        return s;
    }
}
